package com.shiminghui.String;

import java.util.Scanner;

public class Login {
    public static void main(String[] args) {

        String userName = "admin";
        String password = "123456";

        Scanner scanner = new Scanner(System.in);

        for (int i = 0; i<3; i++){
            System.out.println("请输入用户名");
            String userName1 = scanner.next();
            System.out.println("请输入密码");
            String password1 = scanner.next();
            if (userName1.equals(userName)&&password1.equals(password)){
                System.out.println("登录成功");
                return;
            }else {
                System.out.println("用户名或密码错误,请重新输入,还有"+(2-i)+"次机会");
            }
        }
        System.out.println("登陆失败");

    }
}
